/*
 *  Copyright 2009 Lucas Nazário dos Santos
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package net.sourceforge.retriever.sample;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

import net.sourceforge.retriever.Retriever;
import net.sourceforge.retriever.analyzer.Analyzer;
import net.sourceforge.retriever.fetcher.Resource;

/*
 * This sample shows how to crawl resources in the Web and local file system
 * at the same time.
 */
public class CrawlingLocalAndWebResourcesAtTheSameTime {


	public static void main(final String[] args) throws MalformedURLException {

		final Retriever crawler = new Retriever();

		// Seed that points to a Web resource
		crawler.addSeed(new URL("http://sourceforge.net/"));

		// Seed that points to a local file system resource
		crawler.addSeed(new URL("file://c:/"));

		// Prints the URL of resources
		crawler.setAnalyzer(new Analyzer() {
			public void analyze(final Resource resource, final Map<String, Object> additionalInfo) {
				System.out.println(resource.getURL().toExternalForm());
			}
		});

		crawler.start();
	}
}